// 在线率监控图表配置

// 在线设备个数图表配置
const colorList1 = ['rgb(61, 188, 190)', '', 'rgb(50, 84, 221)', '', 'rgb(190, 229, 251)', '', 'rgb(43, 142, 243)', '', 'rgb(60, 212, 149)', '']
const colorList2 = ['rgb(61, 188, 190,0.5)', '', 'rgb(50, 84, 221,0.5)', '', 'rgb(190, 229, 251,0.5)', '', 'rgb(43, 142, 243,0.5)', '', 'rgb(60, 212, 149,0.5)', '']
export const onlineChartOption = {
  title: {
    text: '',
    left: 'center',
    top: '42%',
    itemGap: 10,
    textStyle: {
      color: '#fff',
      fontSize: '30',
      fontWeight: 500
    },
    subtext: '共计',
    subtextStyle: {
      color: 'rgba(255,255,255,0.5)',
      fontSize: '20',
      fontWeight: 600
    }
  },
  tooltip: {
    trigger: 'item',
    axisPointer: {
      // 坐标轴指示器，坐标轴触发有效
      type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
    },
    formatter(params) {
      if (params.data.name) {
        return `${params.name + ':' + params.data.value}`
      }
    },
    // formatter: "{b}: {c} "+" | "+"{d}%",
    textStyle: {
      fontSize: 18,
      color: 'rgba(255,255,255,0.8)'
    },
    borderColor: 'rgba(255,255,255,0.9)',
    backgroundColor: 'rgba(255,255,255,0.5)',
    extraCssText: 'box-shadow: 2px 2px 4px 0px rgba(255,255,255,0.5);'
  },
  series: [
    {
      type: 'pie',
      radius: ['50%', '72%'],
      center: ['50%', '50%'],
      minAngle: 1,
      labelLine: {
        show: false
      },
      label: {
        show: false,
      },
      itemStyle: {
        normal: {
          color: function (params) {
            if (params.name === "在线数量") {
              return "rgb(61, 188, 190)"
            } else if (params.name === "离线数量") {
              return "rgb(190, 229, 251)"
            } else {
              return colorList1[params.dataIndex]
            }
            //return colorList1[params.dataIndex]
          }
        }
      },
      data: [],
      z: 666
    },
    {
      type: 'pie',
      radius: ['80%', '85%'],
      center: ['50%', '50%'],
      hoverAnimation: false,
      minAngle: 1,
      emphasis: { scale: false },
      label: {
        show: false
      },
      itemStyle: {
        normal: {
          color: function (params) {
            if (params.name === "在线数量") {
              return "rgb(61, 188, 190,0.5)"
            } else if (params.name === "离线数量") {
              return "rgb(190, 229, 251,0.5)"
            } else {
              return colorList2[params.dataIndex]
            }
            //return colorList2[params.dataIndex]
          }
        }
      },
      data: [],
      z: 1
    },
  ]
};

// 在线设备容量图表配置
const colorCapList1 = [
  "rgb(43, 142, 243)",
  "",
  "rgb(190, 229, 251)",
  "",
  "rgb(60, 212, 149)",
  "",
  "rgb(61, 188, 190)",
  "",
  "rgb(50, 84, 221)",
  "",
]
const colorCapList2 = [
  "rgb(43, 142, 243,0.5)",
  "",
  "rgb(190, 229, 251,0.5)",
  "",
  "rgb(60, 212, 149,0.5)",
  "",
  "rgb(61, 188, 190,0.5)",
  "",
  "rgb(50, 84, 221,0.5)",
  "",
]
export const offlineChartOption = {
  title: {
    text: '',
    left: 'center',
    top: '42%',
    itemGap: 10,
    textStyle: {
      color: '#fff',
      fontSize: '30',
      fontWeight: 500
    },
    subtext: '共计',
    subtextStyle: {
      color: 'rgba(255,255,255,0.5)',
      fontSize: '20',
      fontWeight: 600
    }
  },
  tooltip: {
    trigger: 'item',
    axisPointer: {
      // 坐标轴指示器，坐标轴触发有效
      type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
    },
    formatter(params) {
      if (params.data.name) {
        return `${params.name + ':' + params.data.value}`
      }
    },
    // formatter: "{b}: {c} "+" | "+"{d}%",
    textStyle: {
      fontSize: 18,
      color: 'rgba(255,255,255,0.8)'
    },
    borderColor: 'rgba(255,255,255,0.9)',
    backgroundColor: 'rgba(255,255,255,0.5)',
    extraCssText: 'box-shadow: 2px 2px 4px 0px rgba(255,255,255,0.5);'
  },
  series: [
    {
      type: 'pie',
      radius: ['50%', '72%'],
      center: ['50%', '50%'],

      minAngle: 0,
      labelLine: {
        show: false
      },
      label: {
        show: false,
      },
      itemStyle: {
        normal: {
          color: function (params) {
            if (params.name === "在线容量") {
              return "rgb(43, 142, 243)"
            } else if (params.name === "离线容量") {
              return "rgb(190, 229, 251)"
            } else {
              return colorCapList1[params.dataIndex]
            }

          }
        }
      },
      data: [],
      z: 666
    },
    {
      type: 'pie',
      radius: ['80%', '85%'],
      center: ['50%', '50%'],
      hoverAnimation: false,
      minAngle: 0,
      emphasis: { scale: false },
      label: {
        show: false
      },
      itemStyle: {
        normal: {
          color: function (params) {
            if (params.name === "在线容量") {
              return "rgb(43, 142, 243,0.5)"
            } else if (params.name === "离线容量") {
              return "rgb(190, 229, 251,0.5)"
            } else {
              return colorCapList2[params.dataIndex]
            }
            //return colorCapList2[params.dataIndex]
          }
        }
      },
      data: [],
      z: 1
    },
  ]
}